

package cn.shengchao.controler.course;

import cn.shengchao.util.helper.LoginHelper;
import cn.shengchao.examstar.comment.ohs.local.appservice.ProductCommentAppService;
import cn.shengchao.examstar.comment.ohs.local.message.CommentDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.continew.starter.web.model.R;

@Tag(name = "产品评论")
@Slf4j
@RestController
@CrossOrigin("${project.cross-origin}")
@RequestMapping("/api/${project.version}/comment")
public class ProductCommentController {

    @Autowired
    private ProductCommentAppService productCommentAppService;

    @PostMapping
    @Operation(summary = "评论", description = "评论")
    public R comment(@RequestBody CommentDto commentDto) {
        log.info("产品：{},用户：{}，评论：{}", commentDto.getProductId(), LoginHelper.getUserId(), commentDto.getContent());
        productCommentAppService.comment(commentDto, LoginHelper.getUserId());
        return R.ok();
    }
}
